package org.tinygroup.xstream.test;

public enum Color {
	RED("红色"), GREEN("绿色"), BLANK("白色"), YELLO("黄色");

	private String name;

	public String getName() {
		return name;
	}

	private Color(String name) {
		this.name = name;
	}

	public static Color toEnum(String color) {

		try {
			return Enum.valueOf(Color.class, color);
		} catch (Exception ex) {
			for (Color colorValue : Color.values ()) {
                if (colorValue.getName().equalsIgnoreCase(color)) {
                    return colorValue;
                }
            }
			throw new IllegalArgumentException("Cannot convert <" + color + "> to Color enum");

		}

	}
}
